package sg.edu.nus.iss.billing.template;

import java.math.BigDecimal;
import java.text.DateFormat;
import java.text.DecimalFormat;
import java.util.Date;

/**
 * @author Daniel
 *
 */
public class ConvertStrategy {
	
	private DecimalFormat decimalFormat;
	private DateFormat dateFormat;
	
	public ConvertStrategy(DecimalFormat decimalFormat) {
		this.decimalFormat = decimalFormat;
	}
	
	public ConvertStrategy(DateFormat dateFormat) {
		this.dateFormat = dateFormat;
	}
	
	public String convert(Object valueObj) {
		String result = "";
		if (valueObj instanceof Date) {
			result = dateFormat.format(valueObj);
		} else if (valueObj instanceof BigDecimal) {
			result = decimalFormat.format(valueObj);
		}
		return result;
	}
	
}
